package com.example.peibei.ui.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.Choose;
import com.example.peibei.R;

public class SelectRequestPaidanList extends BaseQuickAdapter<Choose, BaseViewHolder> {

    private int selectPosition;
    public SelectRequestPaidanList() {
        super(R.layout.item_select_request_paidan_list);
        addChildClickViewIds(R.id.iv_avatar);
        setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                selectPosition = position;
                notifyDataSetChanged();
            }
        });
    }

    public int getSelectPosition() {
        return selectPosition;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, Choose choose) {
        ImageView iv_avatar = baseViewHolder.getView(R.id.iv_avatar);
        Glide.with(getContext()).load(choose.getMemberImg()).into(iv_avatar);
        baseViewHolder.setText(R.id.tv_name,choose.getNickname());
        baseViewHolder.setText(R.id.tv_date,choose.getApplyTime());
        baseViewHolder.setVisible(R.id.iv_selected,getItemPosition(choose) == selectPosition);
    }
}
